<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <include file="./Public/Admin/header.html" />
</head>
<body>

<div id="main">
    <div class="container-fluid">

        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-title">
                        <div class="span10">
                            <h3><i class="icon-edit"></i>编辑管理员</h3>
                        </div>
                        <div class="span2"><a class="btn" href="Javascript:window.history.go(-1)">返回</a></div>
                    </div>
                    <div class="box-content">
                        <form id="form1" action="{:U('Admin/Permission/addusers')}" method="post" class="form-horizontal form-validate">
                        <div class="control-group">
                            <label for="user_type_id" class="control-label">用户角色：</label>
                            <div class="controls">
                                <select name="user_type_id" id="user_type_id">
                                    <option value="0">--请选择--</option>
                                    <?php
                                    $types = M('user_type')->select();
                                    if (count($types) > 0): foreach ($types as $items):
                                    ?>
                                    <option value="<?php echo $items['user_type_id']; ?>" <?php echo $items['user_type_id']==$uinfo['user_type_id']?"selected='selected'":'';?> <?php echo !empty($user_id)?"selected='selected'":'';?>><?php echo $items['user_type_name']; ?></option>
                                    <?php endforeach;endif; ?>
                                </select><span class="maroon">*</span>
                            </div>
                        </div>
                        <!--<div class="control-group">
                            <label for="operation" class="control-label">操作权限：</label>

                            <div class="controls">
                                <select name="operation" id="operation">
                                    <?php if (isset($uinfo['operation']) && $uinfo['operation'] != ''): ?>
                                    <option value="0" <?php if ($uinfo['operation'] == 0) {
                                            echo "selected='selected' ";
                                        } ?> >无
                                    </option>
                                    <option value="1" <?php if ($uinfo['operation'] == 1) {
                                            echo "selected='selected' ";
                                        } ?>>有
                                    </option>
                                    <?php else: ?>
                                    <option value="0" selected="selected">无</option>
                                    <option value="1">有</option>
                                    <?php endif; ?>
                                </select>
                            </div>
                        </div>-->
                        <div class="control-group">
                            <label for="username" class="control-label">用户名：</label>
                            <div class="controls">
                                <input type="text" name="username" id="username" class="input-medium" value="<?php echo !empty($true_name)?$true_name:$uinfo['username']; ?>" data-rule-required="true" <?php echo $action == 'edit' ? 'readonly' : '' ?>/><span class="maroon">*</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label for="userpwd" class="control-label">密码：</label>

                            <div class="controls">
                                <input type="hidden" name="oldpwd" id="oldpwd" value="<?php echo $uinfo['userpwd'] ?>"/>
                                <input name="userpwd" id="userpwd" minlength="6" type="password" class="input-medium" data-rule-required="true" value="<?php echo $uinfo['userpwd'] ?>"><span class="maroon">*</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label for="usernickname" class="control-label">昵称：</label>
                            <div class="controls">
                                <input type="text" name="usernickname" id="usernickname" class="input-medium " data-rule-required="true" value="<?php echo $uinfo['usernickname'] ?>"><span class="maroon">*</span>
                            </div>
                        </div>

                        <div class="control-group">
                            <label for="usermobile" class="control-label">手机：</label>
                            <div class="controls">
                                <input type="text" name="usermobile" id="usermobile" maxlength="11" class="input-medium mobile" value="<?php echo $uinfo['usermobile'] ?>">
                            </div>
                        </div>
                        <div class="control-group">
                            <label for="useremail" class="control-label">邮箱：</label>
                            <div class="controls">
                                <input type="text" name="useremail" id="useremail" class="input-medium email" value="<?php echo $uinfo['useremail'] ?>">
                            </div>
                        </div>
                        <div class="control-group">
                            <label for="userqq" class="control-label">QQ：</label>
                            <div class="controls">
                                <input type="text" name="userqq" id="userqq" class="input-medium" value="<?php echo $uinfo['userqq'] ?>">
                            </div>
                        </div>
                        <div class="form-actions">
                            <input type="hidden" name="action" id="action" value="<?php echo $action ?>"/>
                            <input type="hidden" name="userid" id="userid" value="<?php echo $userid ?>"/>
                            <input type="hidden" name="usertype" id="usertype" value="<?php echo $uinfo['usertype'] ?>"/>
                            <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id ?>"/>
                            <button type="button" id="btnsave" class="btn btn-primary">保存</button>
                            <a class="btn" href="Javascript:window.history.go(-1)">取消</a>
                        </div>
                        </form>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $('#username').focus();

        $("#btnsave").click(function () {
            var user_type_id = $("#user_type_id").val();
            if (user_type_id == "0") {
                alert('请选择用户角色');
                return false;
            }

            var username = $.trim($("#username").val());
            if (username == '') {
                alert('请填写用户名');
                return false;
            }
            var userpwd = $.trim($("#userpwd").val());
            if (userpwd == "") {
                alert('请填写用户密码');
                return false;
            }

            $('#form1').submit();

            /*var usernickname = $.trim($("#usernickname").val());
            var usermobile = $.trim($("#usermobile").val());
            var useremail = $.trim($("#useremail").val());
            var userqq = $.trim($("#userqq").val());
            var action = $("#action").val();
            var userid = $("#userid").val();
            var usertype = $("#usertype").val();
            var operation = $("#operation").val();
            var oldpwd = $("#oldpwd").val();

            var user = {
                username: username,
                usernickname: usernickname,
                usermobile: usermobile,
                useremail: useremail,
                userqq: userqq,
                user_type_id: user_type_id,
                userpwd: userpwd,
                action: action,
                userid: userid,
                usertype: usertype,
                operation: operation,
                oldpwd: oldpwd
            }

            $.post("{:U('Admin/Permission/addusers')}", user, function (data) {
                if(data.errno==0){
                    window.location.href = data.url;
                }else{
                    G.ui.tips.err(data.error);
                }
            }, 'json');*/
        });
    });
</script>
</body>
</html>
